/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package battleship_client.screens;

import java.awt.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
import javax.swing.*;

/**
 *
 * @author dpo89
 */

public class AdminScreen extends Screen {
    
    public AdminScreen(){
        setLookAndFeel();
        initComponents();
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    private void initComponents(){
        
        setTitle("Welcome to Battleship Admin Interface");
        setSize(400, 350);
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        setResizable(false);
        setLocationRelativeTo(null);
        
        lblImage = new JLabel();
        lblImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/400x100.png")));
        lblImage.setBounds(0,0,400,100);
        
        contentPanel = getContentPane();
        mainPanel = new JPanel();
        mainPanel.setLayout(null);
        
        lblUsers = new JLabel("Online Users");
        lblUsers.setBounds(35, 110, 200, 40);
        lblUsers.setFont(new Font("Lucida Grande", 1, 14));
        
        lblActive = new JLabel("Active Games");
        lblActive.setBounds(260, 110, 200, 40);
        lblActive.setFont(new Font("Lucida Grande", 1, 14));
        
        lblActUs = new JLabel("0");
        lblActUs.setBounds(300, 110, 200, 200);
        lblActUs.setFont(new Font("Lucida Grande", 1, 24));
        
        txtaTemp = new JTextArea();
        
        txtaTemp.setBounds(10, 150, 150, 160);
        JScrollPane scrollPane = new JScrollPane(txtaTemp);
        txtaTemp.setEditable(false);
        
        mainPanel.add(lblImage);
        mainPanel.add(lblUsers);
        mainPanel.add(lblActive);
        mainPanel.add(lblActUs);
        mainPanel.add(txtaTemp);
        contentPanel.add(mainPanel);
        
        
   }
   
   public void changeText(String stg){
       txtaTemp.setText(parseArrayList(stg));
   }
   
   public void changeTextActiveG(String st){
       lblActUs.setText(st);
   }
   
   public static void main(String args[]){
       new AdminScreen().setVisible(true);
       
   }
   
   private static String parseArrayList(String st) {
       String result = "";
       st = st.replace("[", "").replace("]", "");
       StringTokenizer stoken = new StringTokenizer(st, ",");
       while(stoken.hasMoreTokens()){
           result += stoken.nextToken().replace(" ", "") + "\n";
       }
       return result;
   }
   
   private Container contentPanel;
   private JPanel mainPanel;
   private JLabel lblUsers, lblActive, lblImage, lblActUs;
   private JTextArea txtaTemp;

}
